﻿//定义js命名空间
Ext.namespace("Hmis.Util");

Hmis.Util.CommonStore = function () {
    var m_depStore = new Ext.data.JsonStore({
        url: '/InfraHospUser/GetDeptList',
        root: 'data',
        totalProperty: 'total',
        id: 'Id',
        fields: [{
            name: 'Id',
            type: 'string'
        }, {
            name: 'Name',
            type: 'string'
        }, {
            name: 'Code',
            type: 'string'
        }]
    });

    return {
        //机构store
        DEPTSTORE: m_depStore,
        //字典store
        GetDictStore: function (dictCategory) {
            var dictionaryStore = new Ext.data.JsonStore({
                url: '/InfraDictionary/GetPlistByCategoryCode?Code=' + dictCategory,
                root: 'data',
                totalProperty: 'total',
                id: 'Code',
                fields: [{
                    name: 'Id',
                    type: 'string'
                }, {
                    name: 'Name',
                    type: 'string'
                }, {
                    name: 'Code',
                    type: 'string'
                }]
            });
            return dictionaryStore;
        }
    };
}();

Hmis.Util.CommonCombox = function () {
    return {
        // 机构下拉
        HmisDeptCombo: function (combLabel, combName) {
            return {
                fieldLabel: combLabel + '<span style="color: red;" >*</span>',
                xtype: 'diccombo',
                name: combName,
                store: Hmis.Util.CommonStore.DEPTSTORE,
                width: 150,
                listWidth: 200
            };
        },
        // 字典下拉
        HmisDictCombo: function (combLabel, dictCategory) {
            return {
                xtype: 'diccombo',
                fieldLabel: combLabel + '<span style="color: red;" >*</span>',
                name: dictCategory,
                store: Hmis.Util.CommonStore.GetDictStore(dictCategory),
                mode: 'remote',
                width: 150,
                listWidth: 200
            };
        }
    }
} ();
